package com.platform.modules.utils;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import lombok.Data;
import org.springframework.stereotype.Component;

/**
 * 腾讯云cos文件上传客户端配置
 * 正式上线更换为自己的id和key
 */
@Component
@Data
public class TencentUtil {
    private String secretId="AKID972mLAktoZ6NUTuBfS3UeuIVr7BzoES1";
    private String secretKey="XqzWaQ2PfgTM0Zlg8wbCdXFgsobGivSn";
    private String bucket="";
    private String bucketName="klwu-1258407086";
    private String path="https://klwu-1258407086.cos.ap-guangzhou.myqcloud.com/";
    private String qianzhui="mengte";
    private String area;

    public COSClient tencentStart(){
        System.out.println(secretId);
        // 1 初始化用户身份信息(secretId, secretKey)
        COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
        // 2 设置bucket的区域, COS地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
        // clientConfig中包含了设置region, https(默认http), 超时, 代理等set方法, 使用可参见源码或者接口文档FAQ中说明
        ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
        // 3 生成cos客户端
        COSClient cosClient = new COSClient(cred, clientConfig);
        return cosClient;
    }
}
